import requests

# requests.request("get", "https://www.baidu.com/sdhao.html")
# # requests.get("https://www.baidu.com/sdhao.html")
# requests.request("post", "https://www.baidu.com/sdhao.html")
# # requests.post("https://www.baidu.com/sdhao.html")
# requests.request("beifan", "https://www.baidu.com/sdhao.html")
# # requests.beifan("https://www.baidu.com/sdhao.html")  # 这么写无法访问自定义方法，需要换成上面的写法


# 变量赋值，输出响应结果
resp = requests.request("get", "https://www.baidu.com/sdhao.html")
print("状态码", resp.status_code)
print("响应头", resp.headers)
print("响应正文（二进制）", resp.content)
print("响应正文（文本）", resp.text)
# print("响应正文（JSON）", resp.json())

resp = requests.request("post", "https://www.baidu.com/sdhao.html")
print("状态码", resp.status_code)
print("响应头", resp.headers)
print("响应正文（二进制）", resp.content)
print("响应正文（文本）", resp.text)
# print("响应正文（JSON）", resp.json())

resp = requests.request("beifan", "https://www.baidu.com/sdhao.html")
print("状态码", resp.status_code)
print("响应头", resp.headers)
print("响应正文（二进制）", resp.content)
print("响应正文（文本）", resp.text)
# print("响应正文（JSON）", resp.json())
